package com.zcx.yun;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo; 

public abstract class NetWordReceiver extends BroadcastReceiver{

	@Override
	public void onReceive(Context context, Intent intent){
		
		ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
		
		NetworkInfo activeNetInfo = connectivityManager.getActiveNetworkInfo();
		
		NetworkInfo mobNetInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
		
		onConnectChange(context, (activeNetInfo != null && activeNetInfo.isAvailable() && activeNetInfo.isConnected())||(mobNetInfo != null && mobNetInfo.isAvailable() && mobNetInfo.isConnected()));
	
	}

	abstract void onConnectChange(Context context, boolean isConnect);
	
}
